package com.sec.web;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.sec.pojo.Test;
import com.sec.service.TestService;

@Namespace(value="/test")
public class TestAction extends ActionSupport {
	
	@Autowired
	private TestService testService;
	
	private Test test;
	
	public Test getTest() {
		return test;
	}
	public void setTest(Test test) {
		this.test = test;
	}

	@Action(value="testAction",results={
			@Result (name="success",location="/WEB-INF/page/ok.jsp")
			
	})
	public String testMainMethod(){
		
		test = testService.insertTest(test);
		if (null!=test) {
			System.out.println("test ok!");
			return SUCCESS;
		}else {
			return ERROR;
		}
	}
	
	
}
